using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using DevExpress.XtraTreeList.Nodes;

using DevExpress.XtraEditors;
using System.Runtime.InteropServices;
using TierApplication;

namespace BasisMgr
{
    public partial class frmDeptSelct : TierService.frmTemplate
    {

        #region "Variable"
        DataSet dsDepartment = new DataSet();
        public string gDeptID = "";
        public string gDeptName = "";
        #endregion
        public frmDeptSelct()
        {
            InitializeComponent();
        }

        private void BindGrid()
        {
            P_Department mDept = new P_Department();
            tlDept.DataSource = mDept.GetList("").Tables[0];
            tlDept.KeyFieldName = "DeptID";
            tlDept.ParentFieldName = "PrevDeptID";
            tlDept.ExpandAll();       
        }

        private void btnQuit_Click(object sender, EventArgs e)
        {
            DialogResult = System.Windows.Forms.DialogResult.Cancel;
        }

        private void tlDept_DoubleClick(object sender, EventArgs e)
        {
            TreeListNode node = tlDept.FocusedNode;

            if (node != null)
            {
                gDeptID = node["DeptID"].ToString();
                gDeptName = node["DeptName"].ToString();
                DialogResult = System.Windows.Forms.DialogResult.OK;
            }
        }

        private void btnModify_Click(object sender, EventArgs e)
        {
            TreeListNode node = tlDept.FocusedNode;

            if (node != null)
            {
                gDeptID = node["DeptID"].ToString();
                gDeptName = node["DeptName"].ToString();
            }
            DialogResult = System.Windows.Forms.DialogResult.OK;
        }

        private void frmDeptSelct_Load(object sender, EventArgs e)
        {
            BindGrid();
        }
    }
}